import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import joblib

csv_path = "../image_true_label_train.csv"
model_path = "../DecisionTree/max_depth3_tree.pth"

font_size = 24
index = 3


if __name__ == "__main__":

    #----------------------#
    #   读取数据集对应的csv
    #----------------------#
    CsvData = pd.read_csv(csv_path)
    feature = CsvData.columns[1:]
    Data = np.array(CsvData.iloc[:, 1:])
    Data_x, Data_y = Data[:, :-1], Data[:, -1].astype(int)

    x = np.array(CsvData.iloc[:, 0])
    #----------------------#
    #   载入模型, 并预测
    #----------------------#
    model = joblib.load(model_path)
    predict_y = model.predict(Data_x)

    from matplotlib import rcParams

    fontconfig = {
        "font.family": 'Times New Roman',  # 设置字体类型
    }

    rcParams.update(fontconfig)

    plt.figure(figsize=(14, 7))
    # plt.scatter(x, Data[:, index], s=1)
    plt.scatter(x, predict_y, s=1, c='r')
    plt.xlabel("frame sample number", fontsize=font_size + 2)
    plt.ylabel(feature[index], fontsize=font_size + 2)
    plt.tick_params(labelsize=font_size)
    plt.tight_layout()
    # plt.savefig("true_label.jpg")
    plt.savefig("predict_label_3.jpg")
    plt.show()


